package com.imooc.demo.web;

import com.imooc.demo.entity.Message;
import com.imooc.demo.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/message")//指定路由
public class MessageController {
    @Autowired
    MessageService messageService;

    //获取所有种类的信息，value = "listmessage"是访问url路由
    @RequestMapping(value = "listmessage",method = RequestMethod.GET)
    private Map<String , Object> listMessage(){
        Map<String , Object>modelMap = new HashMap<String , Object>();
        List<Message> list = messageService.getGongGao();
        modelMap.put("messageList" , list);
        return  modelMap;
    }
}
